package com.project.service.impl;

import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import com.project.mapper.IManMapper;
import com.project.service.ICarService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CarServiceImpl extends BaseService implements ICarService {
    @Override
    public void add(CarBean car) {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        mapper.add(car);
        session.commit();
        session.close();
    }

    @Override
    public List<CarBean> findAll() {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        List<CarBean> list = mapper.findAll();
        session.close();
        return list;
    }

    public static void main(String[] args) {
        ICarService service = new CarServiceImpl();
//        service.add(new CarBean("宝马", 250000, 4));
        System.out.println(service.findAll());
    }
}
